class Snake{
    String name;
    int price;

    private int length;

//    public void setLength(int length){
//        this.length = length;
//    }
//    public int getLength(){
//        return length;
//    }
    //自动生成


    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public void sayInfo(){

        //如果没有变量和属性重名，可以省略this
        System.out.println("我叫"+name);

        int price = 10;
        System.out.println("价值-函数内："+price);//10
        System.out.println("价值-属性："+this.price);//30
    }
}

public class J07fangfaheshuxing {
    public static void main(String[] args) {
        Snake s1 = new Snake();
        s1.name="五步蛇";
        s1.price = 30;
        s1.sayInfo();
    }
}
